< previous page page_65 next page >

Page 65
Puzzle 15
What Time Zone Is It?
If you have ever installed Windows 95/98 or NT 4.0 or later, you may recall that, in one of the final steps in the installation process, you are asked to specify the time zone for your Windows installation.1 You may also have experienced situations where you boot up your machine only to have it notify you that it has switched to or from daylight savings time. Clearly Windows has a fairly sophisticated time sense.
The Win32 API has a number of functions that allow your applications to take advantage of the operating system's support for times and dates. In this puzzle, we'll address the simple task of determining the current time zone, time difference from UTC,2 and whether daylight savings time is in effect. The function that retrieves this information is the GetTimeZoneInformation function, which is declared in the Win32 API documentation as follows:
DWORD GetTimeZoneInformation(
    LPTIME_ZONE_INFORMATION lpTimeZoneInformation   // address of time-zone
                                                    // settings
   );
What is LPTIME_ZONE_INFORMATION?
The first hint is in the prefix LP. LP indicates that the parameter is a pointer, specifically, a pointer to a TIME_ZONE_INFORMATION structure. The Win32 API documentation defines this structure as follows:
typedef struct _TIME_ZONE_INFORMATION { // tzi
    LONG       Bias;
    WCHAR      StandardName[ 32 ];
    SYSTEMTIME StandardDate;
    LONG       StandardBias;
    WCHAR      DaylightName[ 32 ];
    SYSTEMTIME DaylightDate;
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
1 Come to think of it, that's a rather silly question, since anyone reading this book has probably installed these operating systems more times than they would care to remember.
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
2 UTC means Universal Time Coordinates, which is more often called Coordinated Universal Timeunless you're old-fashioned, in which case you call it Greenwich Mean Time or GMT. UTC is the time at 0° longitude, which just happens to pass through Greenwich, England.

 
< previous page page_65 next page >